package com.example.controller;

import com.example.consumer.Bilili;
import com.example.entity.VideoMessage;
import com.example.entity.RestBean;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/video")
public class BililiController {

    @Resource
    Bilili bilili;

    @GetMapping("/bilili")
    public RestBean<List<VideoMessage>> getLogisticsMessages() {
        try {
            // 可能会抛出异常的逻辑
            return RestBean.success(bilili.getMessages());
        } catch (Exception e) {
            // 捕获并处理异常
            e.printStackTrace();
            return RestBean.serverError("获取 B站消息失败", e.getMessage());
        }
    }
}
